package com.efast.dmom.mes.bean.base;

public enum ShiftItemType {
	//0-9为有效工作
	WORK("上班",1),
	OT("加班",2),
	//10--19为会议,可扩展如：11早会12下班总结会13周会等等
	MEETING("会议",10),
	//20--29为吃饭，可扩展21早饭22午饭23晚饭等等
	DINING("吃饭",20),
	//30--39为休息，可扩展31上午中间休息，32下午中间休息等等
	REST("休息",30);
	
	
	private String name;
	private int code;
	
	private ShiftItemType(String name,int code) {
		this.name=name;
		this.code=code;
	}
	
	public static String getName(int code) {
		for(ShiftItemType type:ShiftItemType.values()) {
			if(code == type.getCode()) {
				return type.getName();
			}
		}
		return null;
	}
	
	public static int getCode(String name) {
		if(name ==null){
			return -1;
		}
		for(ShiftItemType type:ShiftItemType.values()) {
			if(name.equals(type.getName())) {
				return type.getCode();
			}
		}
		return -1;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	@Override
	public String toString() {
		return this.code+"_"+this.name;
	}
	
}
